'use strict';

const Controller = require('egg').Controller;

class SetAllcheckedController extends Controller {
  async index() {
    
    const { ctx } = this;
    // var data = await ctx.service.user.find()
    console.log(ctx.request.body)
    var {checked} = ctx.request.body;
    var res = await ctx.model.User.find({},{"cartList":1})
    var cartList = res[0].cartList
    cartList.forEach(item=>{
        item.checked = checked
    })
    await ctx.model.User.updateOne({},{cartList})
    ctx.body ={
      code:200,
      msg:"切换状态成功"
    }
  }
}

module.exports = SetAllcheckedController;
